package com.yanqu.road.server.cmd.activity.pageant;

import com.yanqu.road.entity.enums.eGamePlayerEventType;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.pb.pageant.PageantProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.activity.ActivityRankMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

@Cmd(code = CrossProtocol.C2_PAGEANT_END,desc = "选美结束")
public class CrossSettlementCmd extends CrossCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {

        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        PageantProto.CrossPageantEndReqMsg req = PageantProto.CrossPageantEndReqMsg.parseFrom(packet.getBytes());
        int activityId = req.getActivityId();
        long userId = packet.getPlayerId();
        int singleRank = ActivityRankMgr.getNewCrossActivityRank(activityId, eGamePlayerEventType.PageantSingleScoreCrossRank.getValue(), serverId, userId);
        int totalRank = ActivityRankMgr.getNewCrossActivityRank(activityId, eGamePlayerEventType.PageantTotalScoreCrossRank.getValue(), serverId, userId);
        PageantProto.CrossPageantEndRespMsg.Builder msg = PageantProto.CrossPageantEndRespMsg.newBuilder();
        msg.setSingleRank(singleRank);
        msg.setTotalRank(totalRank);
        YanQuMessage message = YanQuMessageUtils.buildMessage(GameProtocol.S_CROSS_PAGEAN_END, msg);
        MessageHelper.sendPacket(serverId, userId, message);
    }

    @Override
    public void sendData() {

    }
}
